package com.blue.controller;

import com.blue.pojo.Result;
import com.blue.pojo.User;
import com.blue.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/user/{id}")
    public Result selectById(@PathVariable Long id) {
        User user = userService.selectById(id);

        return Result.ok("查询成功", user);
    }

    @RequestMapping("/users")
    public Result selectAll() {
        List<User> users = userService.selectAll();

        return Result.ok("查询成功", users);
    }
}
